package com.thread.lesson.state;

/**
 * @Author: Mr.Xi
 * @Description:
 * @Date: Create in 14:14 2021/7/2
 * @Modified By:
 */

import com.thread.lesson.demo01.TestThread5;

/**
 * 模拟网络延时：放大问题的发生性
 */
public class TestSleep implements Runnable{
    //票数
    private int ticketName = 10;

    @Override
    public void run() {
        while(true){
            if (ticketName <= 0){
                break;
            }
            //模拟延时
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"----->拿到了第"+ticketName--+"票");
        }
    }

    public static void main(String[] args) {
        TestThread5 ticket = new TestThread5();

        new Thread(ticket,"小明").start();
        new Thread(ticket,"老师").start();
        new Thread(ticket,"黄牛党").start();

    }
}
